<template>
  <div class="software-configuration">
    <div class="data-input">
      <div class="title">
        <span>输入配置</span>
        <div class="line"></div>
      </div>
      <div class="input-type">
        <span>数据选择</span>
        <el-select v-model="state.dataType" @change="handleChange" placeholder="请选择">
          <el-option
            v-for="item in state.dataTypeOptions"
            :key="item.value"
            :label="item.label"
            :value="item.value">
          </el-option>
        </el-select>
        <el-upload
          class="upload-demo"
          v-if="state.dataType === '1'"
          :show-file-list="false"
          :auto-upload="false"
          :on-change="(file:any, fileList:any) => fileChange(file, fileList)"
          action="">
          <el-button type="primary">上传文件</el-button>
        </el-upload>
      </div>
    </div>

    <div class="data-output">
      <div class="title">
        <span>输出配置</span>
        <div class="line"></div>
      </div>
      <div class="path">
        <span>IP素材服务始输出路径</span>
        <el-input v-model="state.path" placeholder="请输入输出路径"></el-input>
      </div>
    </div>

    <div class="status">
      <div class="title">
        <span>输出配置</span>
        <div class="line"></div>
      </div>
      <div class="wrapper">
        <div class="item">
          <span>上报时间间隔</span>
          <el-input size="small" placeholder="请输入上报时间间隔" v-model="state.time"></el-input>
          <span>&nbsp;(秒)</span>
        </div>
        <div class="item">
          <span>监控服务IP</span>
          <el-input size="small" placeholder="请输入监控服务IP" v-model="state.watch_ip"></el-input>
        </div>
        <div class="item">
          <span>监控服务端口</span>
          <el-input size="small" placeholder="请输入监控服务端口" v-model="state.watch_port"></el-input>
        </div>
        <div class="item">
          <span>设备编号</span>
          <el-input size="small" placeholder="请输入设备编号" v-model="state.device"></el-input>
        </div>
      </div>
    </div>

    <div class="log">
      <div class="title">
        <span>日志配置</span>
        <div class="line"></div>
      </div>
      <div class="log-time">
        <span>本地日志保存时间</span>
        <el-input size="small" v-model="state.log" placeholder="请输入本地日志保存时间"></el-input>
        <span>&nbsp;(月)</span>
      </div>
    </div>

    <div class="database">
      <div class="title">
        <span>数据库清理</span>
        <div class="line"></div>
      </div>
      <div class="database-time">
        <span>数据保留时间</span>
        <el-input size="small" v-model="state.data_keep_time" placeholder="请输入数据保留时间"></el-input>
        <span>&nbsp;(天)</span>
      </div>
    </div>

    <div class="devices">
      <div class="title">
        <span>设备设置</span>
        <div class="line"></div>
      </div>
      <div class="wrapper">
        <div>
          <span>系统时间</span>
          <el-date-picker
            v-model="state.devices_time"
            type="datetime"
            placeholder="选择日期时间">
          </el-date-picker>
        </div>
        <el-button type="primary" @click="handleClose" :icon="SwitchButton">关闭设备</el-button>
        <el-button type="primary" @click="handleRest" :icon="RefreshRight">重启设备</el-button>
      </div>
    </div>

    <div class="btn-grp">
      <el-button type="primary">重启</el-button>
      <el-button type="primary">保存</el-button>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { SwitchButton, RefreshRight } from "@element-plus/icons-vue";

interface sc {
  dataType:string,
  dataTypeOptions:Array<any>,

  path:string,

  time:string,
  watch_ip:string,
  watch_port:string,
  device:string,

  log:string,

  data_keep_time:string,

  devices_time:string
}

const state = reactive<sc>({
  dataType: '1',
  dataTypeOptions: [
    { label: 'PACP文件数据', value: '1' },
    { label: '实时IP流数据', value: '2' }
  ],

  path: '/flowanalysis/server/public',

  time: '60',
  watch_ip: '134.14.5.36',
  watch_port: '4513',
  device: 'SLWD54565',

  log: '3',

  data_keep_time: '7',

  devices_time: '2023-01-02 00:00:00'
})

const handleChange = (value:any) => {
  if (value === '2') {
    setTimeout(() => {
      ElMessage({
        type: 'success',
        message: '修改成功'
      })
    }, 1000)
  }
}

const fileChange = (file:any, fileList:any) => {
  setTimeout(() => {
    ElMessage({
      type: 'success',
      message: '上传成功'
    })
  }, 1000)
}

const handleClose = () => {}

const handleRest = () => {}
</script>

<style scoped lang="scss">
.software-configuration {
  position: relative;
  min-height: 100%;
  overflow-y: auto;
  background-color: #fff;
  padding: 20px;
  box-sizing: border-box;
  .data-input {
    position: relative;
    margin-bottom: 30px;
  }
  .title {
    margin-bottom: 20px;
    span {
      font-size: 19px;
      color: #0960bd;
      font-weight: 500;
    }
    .line {
      border-bottom: 1px solid #c0c4cc;
      margin-top: 2px;
    }
  }
  .input-type {
    display: flex;
    align-items: center;
    .el-button {
      margin-left: 10px;
    }
    span {
      display: inline-block;
      margin-right: 10px;
      font-size: 14px;
      line-height: 18px;
      color: #666;
      padding-left: 16px;
    }
  }
  .path {
    display: flex;
    margin-bottom: 30px;
    :deep(.el-input) {
      width: 270px;
    }
    span {
      display: inline-block;
      margin-right: 10px;
      font-size: 14px;
      line-height: 32px;
      color: #666;
      padding-left: 16px;
    }
  }
  .status {
    margin-bottom: 30px;
    .wrapper {
      display: flex;
      justify-content: space-between;
      padding-left: 16px;
      box-sizing: border-box;
      .item {
        flex: 1;
        padding-right: 30px;
        box-sizing: border-box;
        display: flex;
        span {
          display: inline-block;
          margin-right: 10px;
          font-size: 14px;
          line-height: 32px;
          color: #666;
        }
        :deep(.el-input) {
          flex: 1;
        }
      }
      div:nth-child(1) {
        width: calc(27% - 30px) !important;
        min-width: 310px;
        padding-right: 20px;
        box-sizing: border-box;
      }
      div:nth-child(4) {
        padding-right: 0px !important;
      }
    }
  }
  .log {
    margin-bottom: 30px;
    .log-time {
      display: flex;
      padding-left: 16px;
      :deep(.el-input) {
        width: 270px;
      }
      span {
        display: inline-block;
        margin-right: 10px;
        font-size: 14px;
        line-height: 32px;
        color: #666;
      }
    }
  }
  .database {
    margin-bottom: 30px;
    .database-time {
      display: flex;
      padding-left: 16px;
      :deep(.el-input) {
        width: 270px;
      }
      span {
        display: inline-block;
        margin-right: 10px;
        font-size: 15px;
        line-height: 32px;
        color: #666;
      }
    }
  }
  .devices {
    .wrapper {
      display: flex;
      padding-left: 16px;
      div {
        margin-right: 6px;
        display: flex;
        span {
          display: inline-block;
          margin-right: 10px;
          font-size: 15px;
          line-height: 32px;
          color: #666;
        }
      }
    }
  }
  .btn-grp {
    position: absolute;
    bottom: 20px;
    right: 20px;
  }
  :deep(.el-input__inner) {
    font-size: 14px;
  }
}
</style>